﻿using CatUtils.Utils.Currency.IoUtils;
using CatUtils.Utils.Helper;
using Service_monitoring.Utils.MailHelper.HelperView;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Service_monitoring.Utils.MailHelper.Telegram
{
    internal class TelegramInfo
    {
        public static string TokenFile = StaticValue.BinPath + "tg.token";
        public static string IdFile = StaticValue.BinPath + "tg.id";

        /// <summary>
        /// 获取保存的token参数
        /// </summary>
        /// <returns></returns>
        public static string GetInfo(string FilePath, string TipText)
        {
            string GetTokenContnet = FileHelper.ReadAllText(FilePath);
            if (GetTokenContnet == "")
            {
                SetTokenForm setToken = new SetTokenForm(TipText, FilePath);
                setToken.ShowDialog();
                return GetInfo(FilePath, TipText);
            }
            return GetTokenContnet;
        }

        /// <summary>
        /// 获取保存的token参数
        /// </summary>
        /// <returns></returns>
        public static string GetToken()
        {
            return GetInfo(TokenFile, "请设置token");
        }

        public static string GetChatId()
        {
            return GetInfo(IdFile, "请设置接收会话的ID");
        }
    }
}